build: Fix libreaddir-rand to honor global CFLAGS
authorColin Walters <walters@verbum.org>
Fri, 17 Jun 2016 13:36:51 +0000 (09:36 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 17 Jun 2016 14:43:44 +0000 (14:43 +0000)
It's unfortunate that in automake one has to explicitly include the globa
`$(AM_CFLAGS)` if one sets `CFLAGS`, and similarly for other variables.

I'm trying to use `-fsanitize=address`, and not including it was
causing linker failures.

We also weren't inheriting the global warnings etc., so I had to fix a
decl-after-statement.

Closes: #351
Approved by: jlebon

Makefile-tests.am
tests/readdir-rand.c

index e5cf9554aaadcbc89f2f8f421187e26173000d56..80903071c5be599a12ef0c5daf6e92c31326f5a7 100644 (file)
@@ -137,12 +137,12 @@ endif
 
 test_ltlibraries = libreaddir-rand.la
 libreaddir_rand_la_SOURCES = tests/readdir-rand.c
-libreaddir_rand_la_CFLAGS = $(OT_INTERNAL_GIO_UNIX_CFLAGS)
+libreaddir_rand_la_CFLAGS = $(AM_CFLAGS) $(OT_INTERNAL_GIO_UNIX_CFLAGS)
 libreaddir_rand_la_LIBADD = \
        -ldl \
        $(OT_INTERNAL_GIO_UNIX_LIBS) \
        $(NULL)
-libreaddir_rand_la_LDFLAGS = -avoid-version
+libreaddir_rand_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
 if !ENABLE_INSTALLED_TESTS
 libreaddir_rand_la_LDFLAGS += -rpath $(abs_builddir)
 endif
index ee43756fb69ed555cce0e06a52f54c9a32f4c1e0..afef387c85c6214ba836743a9341423d39f839f3 100644 (file)
@@ -109,12 +109,12 @@ readdir (DIR *dirp)
        {
          if (g_random_boolean ())
            {
+             struct dirent *copy;
              if (!de)
                {
                  de = dir_entries_new ();
                  g_hash_table_insert (direntcache, dirp, de);
                }
-             struct dirent *copy;
              copy = g_memdup (ret, sizeof (struct dirent));
              g_ptr_array_add (de->entries, copy);
            }